
function getUserInfo() {
  // 马上发送请求, 获取用户信息
  axios.get('/my/user/userinfo').then(res => {
      let { nickname, user_pic, username } = res.data.data;
      let name = nickname || username;
      $('.username').text(name);
      if (user_pic) {
          $('.layui-nav-img').attr('src', user_pic).show();
      } else {
          let first = name.substring(0, 1).toUpperCase();
          $('.user-avatar').text(first).css('display', 'inline-block');
      }
  });

}
getUserInfo()


// function

// -----------------退出功能---------------------
$('#logout').on('click', function () {
  layer.confirm('请您确认是否退出', { icon: 3, title: '提示' }, function (index) {
      localStorage.removeItem('token');
      location.href = './login.html';
      layer.close(index);// 关闭当前弹出层
  });
});